import { App, Body, Controller, Get,Param, Fields,Post,Files, Query } from "@midwayjs/core";
import { Application } from "../interface.js";
import { getFile, uploadfile } from "../config/uploadUtils.js";


@Controller('/api/oss')
export class BookController {
  @App('koa')
  app: Application;

  @Post('/upload')
  async add(@Files() files,@Fields() fields): Promise<any> {
    var reuslt=await uploadfile(files?.[0])
    return reuslt
  }
  @Get('/getimage/:filename')
  async getimage(@Param('filename') filename): Promise<any> {
    var reuslt=await getFile(filename)
    return reuslt
  }


}
